# 1、有这样的一个列表，深度不可知，列表里面还会嵌套列表，
# 我想要把这个列表从左到右拼接成一个新的列表，且顺序不变
# 举例：[12,33,[11,22,33,[55,66,99]],[55,66]]
# 变成：[12, 33, 11, 22, 33, 55, 66, 99, 55, 66]

"""def new_list(para:list):
    new1_list = []
    for i in para:
        if type(i) == list:
            for j in i:
                if type(j) == list:
                    for k in j:
                        new1_list.append(k)
                else:
                    new1_list.append(j)
        else:
            new1_list.append(i)
    print(new1_list)
new_list([12,33,[11,22,33,[55,66,99]],[55,66]])"""

"""def fun_info(list_in):
    list_to = []
    for i in list_in:
        if type(i) == list:
            list_to = list_to + fun_info(i)
        else:
            list_to.append(i)
    return list_to
print(fun_info([12, 33, [11, 22, 33, [55, 66, 99]], [55, 66]]))"""
# 2、编写装饰器，为多个函数加上认证的功能（用户的账号密码）
#  要求登录成功一次，后续的函数都无需输入用户名和密码
# 全局认证状态和预设的账号密码
"""status_ = False
username = 'admin'
password = '123456'

def fun1():
    print("执行后续函数1")
def fun2():
    print("执行后续函数2")
def decorate(func):
    def ogain():
        global status_
        if status_ == False:
            name = input("请输入名字：")
            pwd = input("请输入密码：")
            if name == username and pwd == password:
                status_ = True
                print("登录成功！")
            else:
                print("登录失败")
                return 0
        return func()
    return ogain

ogoin = decorate(fun1)
ogoin()
ogoin = decorate(fun2)
ogoin()"""



# 3、请实现一个装饰器，把函数的返回值+100然后返回
"""def result(num):
    return num

def decorate(func):
    def add1(num):
        func(num)
        r = func(num)
        return r + 100
    return add1
add1 = decorate(result)
print(add1(1))"""

# print(result())

# 4、请实现一个装饰器，通过一次调用使函数重复执行5次
"""def fun4():
    print("hello world")

def decorate(func):
    def again():
        for i in range(5):
            func()
    return again

again = decorate(fun4)
again()"""

# 5、输入任意个字符串,分别实现从小到大输出和从大到小输出
# 方法一
"""def random_str(*args):
    list_ = list(args)
    print(sorted(list_, reverse=False))
    print(sorted(list_,reverse=True))

print(random_str("12","13","44","a"))"""

# 方法二
"""def random_str(*args):
    n = len(args)
    list_in = list(args)
    for i in range(n):
        for j in range(0,n - i - 1):
            if list_in[j] > list_in[j+1]:
                list_in[j],list_in[j+1] = list_in[j+1],list_in[j]
    return list_in

print(random_str("12","13","44","a","3"))"""

# 方法三
"""def random_str(*args):
    list_in = list(args)
    len_ = len(list_in)
    list_to = []
    count = 0
    while count < len_:
        list_to.append(max(list_in))
        list_in.remove(max(list_in))
        count += 1
    return list_to

print(random_str("12","13","44","11","a","b","77","03","05"))"""



# 6、接收n个数字，求这些参数数字的和
"""def sum_n(*args):
    sum = 0
    for i in args:
        sum += i
    return sum

print(sum_n(1, 2, 3, 4, 5, 1, 2, 3, 4))"""

# 7、编写一个函数，实现数字的自增（从0开始，每调用一次，数字+1）
"""def auto_num():
    num = -1
    def num_():
        nonlocal num
        num += 1
        return num
    return num_
num_ = auto_num()
print(num_())
print(num_())
print(num_())
print(num_())
print(num_())
print(num_())
print(num_())
print(num_())
print(num_())"""

print("hello")